package com.javaweb.cwj.controller;


import com.javaweb.cwj.R;
import com.javaweb.cwj.entity.EduVideo;
import com.javaweb.cwj.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-05-13
 */
@RestController
@RequestMapping("eduService/cwj/edu-video")
@CrossOrigin
public class EduVideoController {
    @Autowired
    private EduVideoService eduVideoService;
     @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo eduVideo){
         eduVideoService.save(eduVideo);
        return R.ok();
    }
    @PostMapping("updateVideo")
    public R updateVideo(@RequestBody EduVideo eduVideo){
         eduVideoService.updateById(eduVideo);
         return  R.ok();
    }
    @DeleteMapping("deleteVideo/{videoId}")
    public R deleteVideo(@PathVariable  String videoId){
        eduVideoService.removeById(videoId);
         return R.ok();
    }
    @GetMapping("getVideoById/{videoId}")
    public R getVideoById(@PathVariable String videoId){
         EduVideo eduVideo = eduVideoService.getById(videoId);
         return R.ok().data("eduVideo",eduVideo);
    }
}

